<% /* $Id: index.jsp 132 2011-08-26 10:23:42Z altdotua@gmail.com $ */ %>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%@ include file="../header.jsp" %>

<h1 align="center"><%= bundle.getString("W_CONTESTS_LIST") %></h1>

<table>
	<tr bgcolor="Gainsboro">
		<th>ID</th>
		<th><%= bundle.getString("W_NAME") %></th>
		<th><%= bundle.getString("W_TYPE") %></th>
		<th><%= bundle.getString("W_START_TIME") %> (GMT)</th>
		<th><%= bundle.getString("W_FINISH_TIME") %> (GMT)</th>
		<th><%= bundle.getString("W_STATE") %></th>
	</tr>
<%
	List<ContestEntry> entries = ContestsModel.getAllEntries();
//	Map<Long, ContestScoreEntry> contestScores = ContestScoreModel.getEntriesMap();
	for (ContestEntry entry: entries)
	{
		if (entry.getSid().equals("default"))
			continue;
		
		String state, color;
		Date now = new Date();
		if (entry.getStartTime().after(now))
		{
			state = "Заплановане";
			color = "yellow";
		}
		else if (entry.getFinishTime().before(now))
		{
			state = "Закінчилося";
			color = "green";
		}
		else
		{
			state = "Триває...";
			color = "#ff0000";
		}
			
%>
		<tr align="center">
			<td><%= entry.getActive() ? entry.getSid() : "<font color='red'>" + entry.getSid() + "</font>" %></td>
			<td><a href="<%= Linker.link("contests/home.jsp?contest_id=" + entry.getId()) %>"><%= entry.getName() %></a></td>
			<td><%= entry.getContestType() %></td>
			<td><%= entry.getStartTime() %></td>
			<td><%= entry.getFinishTime() %></td>
			<td bgcolor="<%=color %>"><%= state %></td>
		</tr>
<%
	}
%>
</table>

<%@ include file="../footer.jsp" %>
